package com.lynn.salary.util;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import org.apache.commons.digester.Digester;
import org.apache.commons.digester.xmlrules.DigesterLoader;

public class PageParase {

	public static PageParase instance = new PageParase();

	private PageParase() {
	}

	public Page paraseFromStream(InputStream is) throws Exception {
		try {
			Digester digester = DigesterLoader
					.createDigester(PageParase.class
							.getClassLoader()
							.getResource(
									"parase.xml"));
			Page result = (Page) digester.parse(is);
			return result;
		} catch (Exception e) {
			System.out.println("报文解析失败");
			e.printStackTrace();
			throw e;
		}
	}

	public Page paraseFromString(String soap) throws Exception {
		return paraseFromStream(new ByteArrayInputStream(soap.getBytes("UTF-8")));
	}
}
